//引用Express
const express = require('express');
const app = express(); //实例化express

//express实例的set方法
app.set('port', 3000);

const router = express.Router();

router.get('/', (req, res) => {
    res.send('<h1>我是router-demo的首页</h1>');
});

router.get('/about', (req, res) => {
    res.send('<h1>我是router-demo的关于页面</h1>');
});

app.use('/api', router);

//用Express 实例监听3000端口
app.listen(app.get('port'), () => {
    // 监听成功后要干什么
    console.log('Express服务器已启动。监听端口:', app.get('port'));
});